package cn.shujuhai.cms.config;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.beans.factory.annotation.Value;

/**
 * @Author: NiuYaHu
 * @Date: 2025/8/14 09:50
 * @Description:
 **/
@Configuration
@RequiredArgsConstructor
public class StaticPageConfig implements WebMvcConfigurer {
    //    @Value("${base-path}")
//    private String basePath;
    private final StaticPageInterceptor staticPageInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器，拦截路径为 "/work/channel/**" 的请求
        registry.addInterceptor(staticPageInterceptor)
                .addPathPatterns("/channel/zh-CN/**")
                .addPathPatterns("/channel/en/**")
                .addPathPatterns("/article/en/**")
                .addPathPatterns("/article/zh-CN/**"); // 拦截所有请求

    }
}